package com.eos.control.action.emp;

import com.eos.business.service.SysUserBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.DataCacheUtil;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysRole;

public class DeleteRoleAction extends AbstractBaseAction {
	private static final long serialVersionUID = 8303810255235994753L;
	private Integer roleId;
	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}
	@Override
	public String execute(){
		try{
			if(null == roleId || roleId.longValue() <=0){
				statusCode = "300";
				message = "参数错误, 删除角色失败!";
			}else{
				SysUserBusinessService sbs = new SysUserBusinessService();
				SysRole role = new SysRole();
				role.setId(roleId);
				role.setDealFlag(ConstantTool.DEAL_FLAG_FAIL);
				String exeStatus = sbs.updateSysRoleByPrimaryKeySelective(role);
				if("SUCCESS".equals(exeStatus)){
					statusCode = "200";
					message = "删除角色成功!";
					//更新缓存中的角色
					DataCacheUtil.clearSysRoleMap();
				}else{
					statusCode = "300";
					message = "系统繁忙, 删除角色失败!";
				}
			}
		}catch(Exception ex){
			ex.printStackTrace();
			statusCode = "300";
			message = "系统异常, 删除角色失败!";
		}
		return SUCCESS;
	}
}
